package org.itfarmer.dao.impl;

import java.util.List;

import org.hibernate.Query;
import org.itfarmer.dao.UserDAO;
import org.itfarmer.dao.pojo.User;

@SuppressWarnings("unchecked")
public class UserDAOImpl extends BaseDAOImpl<User, Integer> implements UserDAO{

	/*
	 * (non-Javadoc)
	 * @see org.itfarmer.dao.UserDAO#readByEmail(java.lang.String)
	 */
	/* (non-Javadoc)
	 * @see org.itfarmer.dao.UserDAO#readByEmail(java.lang.String)
	 */
	public User readByEmail(String email) {
		this.init();
		String queryString = "from User where email=?";
		Query query = session.createQuery(queryString);
		List<User> list = query.setString(0, email).list();
		return list == null || list.size() <= 0	? null : list.get(0);
	}

	/*
	 * (non-Javadoc)
	 * @see org.itfarmer.dao.UserDAO#readByPhone(java.lang.String)
	 */
	public User readByPhone(String phone) {
		this.init();
		String queryString = "from User where phone=?";
		Query query = session.createQuery(queryString);
		List<User> list = query.setString(0, phone).list();
		return list == null || list.size() <= 0	? null : list.get(0);
	}

	
}
 